function isIE()
{
	ua = navigator.userAgent.toLowerCase();
	if( ua.indexOf( "msie" ) != -1 )
		return 1;
	else
		return 0;
}

function DisableAll()
{
	for (x=0;x<document.forms[0].elements.length;x++)
        {
                if ((document.forms[0].elements[x].name != "enabled" ) && (document.forms[0].elements[x].type != "submit") && (document.forms[0].elements[x].type != "hidden" ))
                        document.forms[0].elements[x].disabled=true;
        }
}

function EnableAll()
{
        for (x=0;x<document.forms[0].elements.length;x++)
        {
                if ((document.forms[0].elements[x].name != "enabled" ) && (document.forms[0].elements[x].type != "submit") && (document.forms[0].elements[x].type != "hidden" ))
                        document.forms[0].elements[x].disabled=false;
	}
}

function EnabledControl(nume,valoare)
{
	document.write("<tr><td align=\"right\">"+nume+"&nbsp;</td>");
	document.write("<td><select name=\"enabled\" onChange=\"EnabledChange(this)\">");
	document.write("<option value=\"0\"");
	if(valoare == 0) document.write(" selected>");
	else             document.write(">");
	document.write("Disabled</option>");
	document.write("<option value=\"1\" ");
	if(valoare == 1) document.write("selected>");
	else             document.write(">");
	document.write("Enabled</option>");
	document.write("</select></td></tr>");
}

// De aici

function topex_pgh(Locat,SubLocat,RemUser)
{
	document.write("<div>");
	document.write("<table width=\"100%\" height=\"45px\" cellspacing=\"0\" cellpadding=\"5\" style=\"border: 0px;\"><tr class=\"bkbrand\">");
	if( SubLocat != "None" )
		document.write("<td align=\"left\">Location: "+Locat+" > "+SubLocat+"<br>Remote User: "+RemUser+"</td>");
	else
		document.write("<td align=\"left\">Location: "+Locat+"<br>Remote User: "+RemUser+"</td>");
	document.write("<td align=\"right\">Everything Connects</td></tr></table>");
	document.write("</div>");
}

function topex_dla(DescName) 
{ document.write("<dl class=\"topdl\">"); }

function topex_dli(item, DescText) 
{ document.write("<dt class=\"topdt\">"+ item +"</dt><dd class=\"descriere\">"+ DescText +"</dd>"); }

function topex_dlo()	
{ document.write("</dl>"); }

function topex_wboxa(titlu)
{ document.write("<div class=\"wbox\"><div class=\"tbox\">"+titlu+"</div>");}

function topex_wboxo()
{ document.write("</div>"); }

function topex_forma(formfile)
{ document.write("<form action=\""+formfile+"\" method=\"POST\">"); }

function topex_formf(formfile)
{ document.write("<form action=\""+formfile+"\" method=\"POST\" enctype=\"multipart/form-data\">");}

function topex_formo()
{
tmp="<br><p class=\"topform\">";
tmp+="<input type=\"submit\" value=\"Save\" name=\"send\">&nbsp;";
tmp+="<input type=\"submit\" value=\"Cancel\" name=\"send\">&nbsp;";
tmp+="<input type=\"submit\" value=\"Default\" name=\"send\"><\p>";
tmp+="<p class=\"topform\">Please use the COMMIT button to activate your changes</center></p>";
tmp+="</form>";
document.write(tmp);
}

function topex_formr()
{
tmp="<br><p class=\"topform\">";
tmp+="<input type=\"submit\" value=\"New\" name=\"send\">&nbsp;";
tmp+="<input type=\"submit\" value=\"Save\" name=\"send\">&nbsp;";
tmp+="<input type=\"submit\" value=\"Cancel\" name=\"send\">&nbsp;";
tmp+="<input type=\"submit\" value=\"Default\" name=\"send\"><\p>";
tmp+="<p class=\"topform\">Please use the COMMIT button to activate your changes</center></p>";
tmp+="</form>";
document.write(tmp);
}

function topex_formc(nume,sfat)
{
tmp="<br><p class=\"topform\">";
tmp+="<input type=\"submit\" value=\""+nume+"\" name=\"send\">&nbsp;";
tmp+="<\p>";
tmp+="<p class=\"topform\">"+sfat+"</center></p>";
tmp+="</form>";
document.write(tmp);
}

function topex_ctla()
{ document.write("<div class=\"topctrl\"><table align=\"center\" class=\"toptab\">"); }

function topex_ctlr(descriere, nume, valoare, bifa )
{
	tmp="<tr><td class=\"topctl\" align=\"left\" colspan=\"2\"><input name=\""+nume+"\" type=\"radio\" value=\""+valoare+"\" "
	tmp+= ( bifa == valoare ) ? "checked>" : ">"; 
	document.write( tmp+descriere+"&nbsp;</td></tr>" );
}

function topex_ctlcb(descriere, nume, bifa )
{
	tmp="<tr><td class=\"topckb\" align=\"left\" colspan=\"2\"><input name=\""+nume+"\" type=\"checkbox\" value=\"yes\" "
	tmp+= ( bifa == "yes" ) ? "checked>" : ">"; 
	document.write( tmp+descriere+"&nbsp;</td></tr>" );
}

function topex_ctlts(descriere)
{
	document.write("<tr><td class=\"topckb\" align=\"left\" colspan=\"2\">"+descriere+"&nbsp;</td></tr>");
}

function topex_ctli(descriere, nume, valoare)
{
	document.write("<tr><td align=\"right\" class=\"topctl\">"+descriere+"&nbsp;</td>");
	document.write("<td class=\"topctl\"><input name=\""+nume+"\" type=\"text\" align=\"right\" value=\""+valoare+"\"></td></tr>");
}

function topex_ctlf(descriere)
{
	document.write("<tr><td align=\"right\" class=\"topctl\">"+descriere+"&nbsp;</td>"); 
	document.write("<td align=\"center\"  class=\"topctl\"><input type=\"file\" name=\"uploadfile\"></td></tr>"); 
}

function topex_ctlt(descriere, valoare)
{
	document.write("<tr><td align=\"right\" class=\"topctl\">"+descriere+"&nbsp;</td>");
	document.write("<td class=\"topctl\">"+valoare+"</td></tr>");
}

function topex_ctls_onChange(myselect, mydoc)
{
	switch(myselect.name)
	{
	case "interface":
		alert('You just double clicked me!');
		break;
	default:
		break;
	}
}

function topex_ctls(nume,descriere,elemente,selectie)
{
	tmp="<tr><td align=\"right\" id=\"first\" class=\"topctl\">"+descriere+"&nbsp;</td>";
	tmp+="<td class=\"topctl\" id=\"first\"><select name=\""+nume+"\">";
	for(i=0;i<elemente.length;i++)
	{
		if(elemente[i]==selectie) vsel="selected"
		else			  vsel=""
		tmp+="<option value=\""+elemente[i]+"\""+vsel+">"+elemente[i]+"</option>";
	}
	tmp+="</select></td></tr>";
	document.write(tmp);
}

function topex_ctlo() 
{ document.write("</table></div><br>"); }

function topex_sels()
{
	tmp="<td class=\"topport\">"
	tmp+="<select name=\"target\">";
	tmp+="<option value=\"1\" selected>Enable</optio>"
	tmp+="<option value=\"0\">Disable</option></select></td>"
	document.write(tmp);
}

function topex_porta()
{
	tmp=("<div class=\"topctrl\"><table align=\"center\" class=\"toptab\"><tr>");
	tmp+=("<td class=\"tophead\">Port</td>");
	tmp+=("<td class=\"tophead\">Type</td>");
	tmp+=("<td class=\"tophead\">Status</td>");
	tmp+=("<td class=\"tophead\">Category</td>");
	tmp+=("<td class=\"tophead\">Target</td>");
	tmp+=("<td class=\"tophead\">Advanced</td></tr>");
	document.write(tmp);
}

function topex_porti(nr, nume, stare, category, tinta)
{
	document.write("<tr><td class=\"topport\">"+nr+"</td><td class=\"topport\">"+nume+"</td>");
	topex_sels();
	document.write("<td class=\"topport\">"+category+"</td>");
	document.write("<td class=\"topport\">"+tinta+"</td><td class=\"topport\">Edit</td></tr>");
}

function topex_porto()
{ document.write("</table></div>");}

function topex_realma()
{
	tmp=("<div class=\"topctrl\"><table align=\"center\" class=\"toptab\"><tr>");
	tmp+=("<td class=\"tophead\">Realm</td>");
	tmp+=("<td class=\"tophead\">Name</td>");
	tmp+=("<td class=\"tophead\">Status</td>");
	tmp+=("<td class=\"tophead\">Type</td>");
	tmp+=("<td class=\"tophead\">Direction</td>");
	tmp+=("<td class=\"tophead\">Advanced</td></tr>");
	document.write(tmp);
}

function topex_realmi(nr, nume, stare, categorie, directie)
{
	document.write("<tr><td class=\"topport\">"+nr+"</td><td class=\"topport\">"+nume+"</td>");
	document.write("<td class=\"topport\">"+stare+"</td>");
	document.write("<td class=\"topport\">"+categorie+"</td>");
	document.write("<td class=\"topport\">"+directie+"</td><td class=\"topport\"><a href=\"voip-realm.html\">View </a><a href=\"voip-realm.html\">Edit </a><a href=\"voip-realm.html\">Del </a></td></tr>");
}

function topex_realmo()
{
	document.write("</table></div>");
}

function topex_tabsa(captab)
{
	tmp=("<div class=\"topctrl\"><table align=\"center\" class=\"toptab\"><tr>");
	for(i=0;i<captab.length;i++)
	{
		tmp+="<td class=\"tophead\">"+captab[i]+"</td>";
	}
	tmp+="</tr>";
	document.write(tmp);
}

function topex_tabsi(linie)
{
	tmp="<tr>";
	for(i=0;i<linie.length;i++)
	{
		tmp+="<td class=\"topport\">"+linie[i]+"</td>";
	}
	tmp+="</tr>";
	document.write(tmp);
}

function topex_tabso()
{
	tmp="</table><br></div>";
	document.write(tmp);
}

var nrlinie=1;

function topex_taba(captab)
{
	nrlinie=1;
	tmp=("<div class=\"topctrl\"><table align=\"center\" class=\"toptab\"><tr>");
	tmp+=("<td class=\"tophead\">Nr</td>");
	for(i=0;i<captab.length;i++)
	{
		tmp+="<td class=\"tophead\">"+captab[i]+"</td>";
	}
	tmp+=("<td class=\"tophead\">Action</td>");
	tmp+="</tr>";
	document.write(tmp);
}

function topex_tabi(linie, editlink, id)
{
	tmp="<tr>";
	tmp+="<td class=\"topport0\">"+nrlinie+"</td>";
	nrlinie++;
	for(i=0;i<linie.length;i++)
	{
		tmp+="<td class=\"topport\">"+linie[i]+"</td>";
	}
	tmp+="<td class=\"tophead\">";
	tmp+="<a href=\""+editlink+"?id="+id+"&send=edit\">Edit</a>&nbsp;";
	tmp+="<a href=\""+editlink+"?id="+id+"&send=del\">Del</a>&nbsp;";
	tmp+="</td>";
	tmp+="</tr>";
	document.write(tmp);
}

function topex_tabia(linie, editlink, id)
{
	tmp="<tr>";
	tmp+="<td class=\"topport0\">"+nrlinie+"</td>";
	nrlinie++;
	for(i=0;i<linie.length;i++)
	{
		tmp+="<td class=\"topport\">"+linie[i]+"</td>";
	}
	tmp+="<td class=\"tophead\">";
	tmp+="<a href=\""+editlink+"?id="+id+"&send=edit\">Edit</a>&nbsp;";
	tmp+="</td>";
	tmp+="</tr>";
	document.write(tmp);
}

function topex_tabo(captab)
{
	tmp="</table><br></div>";
	document.write(tmp);
}

function topex_hidden(nume,valoare)
{
	document.write("<input type=\"hidden\" name=\""+nume+"\" value=\""+valoare+"\">");
}

function topex_rowa()
{
	document.write("<tr><td class=\"tophead\">"+nrlinie+"</td>");
	nrlinie++;
}

function topex_rowt(valoare)
{
	document.write("	<td class=\"tophead\">"+valoare+"</td>");
	nrlinie++;
}

function topex_rowi(varnum, valoare)
{
	document.write("<td class=\"tophead\"><input name=\""+varnum+"\" type=\"text\" align=\"right\" value=\""+valoare+"\"></td>");
}

function topex_rows(varnum, valoare, elemente )
{
	tmp="<td class=\"tophead\"><select name=\""+varnum+"\">";
	for(i=0;i<elemente.length;i++)
	{
		if(elemente[i]==valoare) vsel="selected"
		else			  vsel=""
		tmp+="<option value=\""+elemente[i]+"\""+vsel+">"+elemente[i]+"</option>";
	}
	tmp+="</select></td>";
	document.write(tmp);
}

function topex_rows1(varnum, valoare, elemente, valori )
{
	tmp="<td class=\"tophead\"><select name=\""+varnum+"\">";
	for(i=0;i<elemente.length;i++)
	{
		if(elemente[i]==valoare) vsel="selected"
		else			  vsel=""
		tmp+="<option value=\""+valori[i]+"\""+vsel+">"+elemente[i]+"</option>";
	}
	tmp+="</select></td>";
	document.write(tmp);
}

function topex_rowo(editlink,id)
{
	tmp="<td class=\"tophead\">";
	tmp+="<a href=\""+editlink+"?id="+id+"&send=cancel\">Exit</a>&nbsp;";
	tmp+="<a href=\""+editlink+"?id="+id+"&send=del\">Del</a>&nbsp;";
	tmp+="</td></tr>";
	document.write(tmp);
	topex_hidden("id",id);
}


function topex_rowoa(editlink,id)
{
	tmp="<td class=\"tophead\">";
	tmp+="<a href=\""+editlink+"?id="+id+"&send=cancel\">Exit</a>&nbsp;";
	tmp+="</td></tr>";
	document.write(tmp);
	topex_hidden("id",id);
}
